package com.gopay.checkorder.service.task.thread;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.gopay.checkorder.service.CheckTpasOrderService;
import com.gopay.common.constants.bank.BankOrderStatus;
import com.gopay.common.domain.bank.tpas.TpasOrder;
@Service("checkWachgeOrderTaskThread")
public class CheckWachgeOrderTaskThread implements Runnable {
	 private final static Logger logger = LoggerFactory.getLogger("CHECK_ORDER");
		@Resource(name = "checkWachgeOrderService")
	    private CheckTpasOrderService checkWachgeOrderService;
		private LinkedBlockingQueue<TpasOrder> queue;
		private CountDownLatch latch;
	    @Override
	    public void run() {
	    	TpasOrder order = queue.poll();
	    	logger.error("==============CheckWachgeOrderTaskThread running :"+order);
	    	checkWachgeOrderService.checkOrder(order, BankOrderStatus.AUTO_CHECK_SUCCESS);
	    }

        public LinkedBlockingQueue<TpasOrder> getQueue() {
            return queue;
        }

        public void setQueue(LinkedBlockingQueue<TpasOrder> queue) {
            this.queue = queue;
        }

        public CountDownLatch getLatch() {
			return latch;
		}

		public void setLatch(CountDownLatch latch) {
			this.latch = latch;
		}
}
